use std::iter;

pub fn odd_fibnacci_sum(threshold: u32) -> u32 {
    iter::repeat(0)
        .scan((0u32, 1), |(a, b), _| {
            (*a, *b) = (*b, *a + *b);
            Some(*a)
        })
        .take_while(|n| *n < threshold)
        .filter(|&n| n % 2 == 1)
        .sum()
}
